import { Inject } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { SupplierPaymentTermEntity } from '../../entity/payment_term';
import { SupplierPaymentTermService } from '../../service/payment_term';
import { SupplierSupplierEntity } from '../../entity/supplier';

/**
 * 供应商账期
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: SupplierPaymentTermEntity,
  service: SupplierPaymentTermService,
  pageQueryOp: {
    fieldEq: ['a.termType', 'a.settlementMethod'],
    select: ['a.*', 'b.name as supplierName'],
    join: [
      {
        entity: SupplierSupplierEntity,
        alias: 'b',
        condition: 'a.supplierId = b.id',
        type: 'leftJoin',
      },
    ],
  },
})
export class AdminSupplierPaymentTermController extends BaseController {
  @Inject()
  supplierPaymentTermService: SupplierPaymentTermService;
}
